<?php

namespace App\Http\Controllers\Agency;
use App\Http\Controllers\Controller;
use App\Services\GiftService;
use Illuminate\Http\Request;
use hg\apidoc\annotation as Apidoc;
/**
 * 礼物管理
 * @Apidoc\Group("market")
 */
class GiftController extends Controller
{
    /**
     * @Apidoc\Title ("礼物管理-礼物记录")
     * @Apidoc\Url("/agency/getGiftRecord")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",desc="页数")
     * @Apidoc\Param("pageSize",type="int",desc="每页条数")
     * @Apidoc\Param("mid",type="int",desc="赠送者id")
     * @Apidoc\Param("username",type="string",desc="赠送者昵称")
     * @Apidoc\Param("giftname",type="string",desc="礼物名称")
     * @Apidoc\Returned("id",type="int",desc="id")
     * @Apidoc\Returned("mid",type="int",desc="发布者id")
     * @Apidoc\Returned("fee",type="string",desc="礼物费用")
     * @Apidoc\Returned("nums",type="string",desc="赠送个数")
     * @Apidoc\Returned("giftName",type="string",desc="礼物名称")
     * @Apidoc\Returned("giftUrl",type="string",desc="礼物图片链接")
     * @Apidoc\Returned("created_at",type="object",desc="发布时间")
     * @Apidoc\Returned("base",type="object",desc="赠送用户基本信息")
     * @Apidoc\Returned("obase",type="object",desc="被赠送用户基本信息")
     */
    public function getGiftRecord(Request $request ,GiftService $giftService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $giftService->getGiftRecord($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("礼物管理-礼物列表")
     * @Apidoc\Url("/agency/getGiftList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",desc="页数")
     * @Apidoc\Param("pageSize",type="int",desc="每页条数")
     * @Apidoc\Param("mid",type="int",desc="赠送者id")
     * @Apidoc\Param("username",type="string",desc="赠送者昵称")
     * @Apidoc\Param("giftname",type="string",desc="礼物名称")
     * @Apidoc\Returned("id",type="int",desc="id")
     * @Apidoc\Returned("giftname",type="int",desc="礼物名称")
     * @Apidoc\Returned("url",type="string",desc="礼物图片链接")
     * @Apidoc\Returned("fee",type="string",desc="单价")
     * @Apidoc\Returned("income",type="string",desc="礼物积分")
     * @Apidoc\Returned("created_at",type="object",desc="添加时间")
     */
    public function getGiftList(Request $request ,GiftService $giftService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $giftService->getGiftList($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("礼物管理-保存礼物")
     * @Apidoc\Url("/agency/gitfUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param ("giftname",type="int",desc="礼物名称")
     * @Apidoc\Param("url",type="string",desc="礼物图片链接")
     * @Apidoc\Param("fee",type="string",desc="单价")
     * @Apidoc\Param("income",type="string",desc="礼物积分")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function giftUpdate(Request $request ,GiftService $giftService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $giftService->giftUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("礼物管理-删除礼物")
     * @Apidoc\Url("/agency/giftDel")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=true,desc="列表id")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function giftDel(Request $request ,GiftService $giftService)
    {
        $params = $request->input();
        $result = $giftService->giftDel($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }
}
